package com.cskaoyan.controller.wx.search;

import com.cskaoyan.bean.MarketKeyword;
import com.cskaoyan.bean.MarketSearchHistory;
import com.cskaoyan.bean.bo.wx.search.WxSearchIndexVo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.service.wx.search.WxSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author erdonc
 * @date 2022/9/9 15:11
 * @description: TODO 搜索模块
 */
@RestController
@RequestMapping("wx/search")
public class WxSearchController {

    @Autowired
    WxSearchService searchService;


    /**
     * @description: TODO 点击搜索框，显示热搜，和历史记录
     * @date: 2022/9/9 16:18
     * @param: []
     */
    @RequestMapping("index")
    public BaseRespVo index() {
        WxSearchIndexVo searchIndexVo = searchService.index();
        return BaseRespVo.ok(searchIndexVo);
    }


    /**
     * @description: TODO  搜索框输入要搜索的商品关键字
     * Request URL: http://182.92.235.201:8083/wx/search/helper?keyword=%E6%89%8B%E6%9C%BA
     * @date: 2022/9/9 17:43
     * @param: []
     */
    @RequestMapping("helper")
    public BaseRespVo helper(String keyword) {
        List<String> key = searchService.helper(keyword);
        return BaseRespVo.ok(key);
    }


    /**
     * @description: TODO 清空搜索历史
     * Request URL: http://182.92.235.201:8083/wx/search/clearhistory
     * @date: 2022/9/9 19:07
     * @param: []
     */
    @RequestMapping("clearhistory")
    public BaseRespVo clearhistory() {
        searchService.clearhistory();
        return BaseRespVo.ok(null);
    }
}
